package com.slz3.business.module.goodsManagement.gooTypeLevel1.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;
import org.springframework.util.MultiValueMap;

import java.time.LocalDateTime;

public class GooTypeLevel1Factory {

    /**
     * 初始化基础属性值
     */
    public static GooTypeLevel1 initBaseFields(GooTypeLevel1 gooTypeLevel1) {
        if (gooTypeLevel1.getUuid() == null) {
            gooTypeLevel1.setUuid(UUIDUtils.generateUUID());
            gooTypeLevel1.setCreateTime(LocalDateTime.now());
            if (VE.isEmpty(gooTypeLevel1.getSerAudit())) {
                gooTypeLevel1.setSerAudit(AuditFlag.WAIT_SUBMIT);
            }
            if (VE.isEmpty(gooTypeLevel1.getSerUsing())) {
                gooTypeLevel1.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            gooTypeLevel1.setLastModifyTime(LocalDateTime.now());
        }
        return gooTypeLevel1;
    }

    public static GooTypeLevel1Condition newGooTypeLevel1Condition(MultiValueMap<String, String> params) {
        GooTypeLevel1Condition condition = new GooTypeLevel1Condition();
        String gooType = params.getFirst("gooTypeName");
        condition.setGooTypeName(gooType);
        return condition;
    }

    /**
     * 初始化基础属性值
     */
    public static GooTypeLevel1 initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static GooTypeLevel1 newTemStyle() {
        return new GooTypeLevel1();
    }

    public static GooTypeLevel1 newObj() {
        return new GooTypeLevel1();
    }
}
